package com.qf.lanzhou.blog.api.dao.Impl;

import com.qf.lanzhou.blog.api.dao.PraiserModifyDao;
import com.qf.lanzhou.blog.api.util.DruidUtil;
import org.apache.commons.dbutils.*;

import java.sql.SQLException;

/**
 * @Author jian
 * @Date 2020/12/17 15:21
 * @JDK 1.8
 * @Version 1.0
 */
public class PraiserModifyDaoimpl implements PraiserModifyDao {
    private QueryRunner queryRunner = new QueryRunner(DruidUtil.getDataSource());
    @Override
    public int updates(String userId, String articleId) {
        String sql="update  t_praise  set  praise_status=0  where  user_id=? and article_id=?";
        BeanProcessor bean = new GenerousBeanProcessor();
        RowProcessor processor = new BasicRowProcessor(bean);
        Object[] params ={userId,articleId};
        try {
            return queryRunner.update(sql,params);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return 0;
    }
}
